<?php
class Util_User {
    public static function getUserInfo($uid){
        $query = DB::select()
            ->from('user_v2')
            ->where('uid','=',$uid)
            ->execute();

        $utype = $query->get('utype');

        if($utype == 'TOURIST'){
            $guider = new Util_Tourist();
            $data = $guider->getTouristInfoById($uid);
        }else{
            $guider = new Util_Guider;
            $data = $guider->getGuiderInfoById($uid);
        }
        return $data;

    }

    public static function user_online($uid){
        $cache = Cache::instance('file');
        $key = md5($uid);
        $cache->set($key,1,300);
    }

    public static function user_offline($uid){
        $cache = Cache::instance('file');
        $key = md5($uid);
        $cache->set($key,0,300);
    }

    public static function is_online($uid){
        $cache = Cache::instance('file');
        $key = md5($uid);
        $data = $cache->get($key);
        if($data == 1){
            return true;
        }else{
            return false;
        }
    }

}